<?php

namespace app\admin\controller;

use app\admin\service\LineMenuService;

class MenuController extends CommonController
{
    //线路菜单，分页列表
    public function getLineMenuList()
    {
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineMenuService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    //线路菜单的详细信息
    public function getLineMenuDetail()
    {
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineMenuService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

    //添加线路菜单
    public function toAddLineMenu()
    {
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineMenuService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    //更新线路菜单
    public function toUpdateLineMenu()
    {
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineMenuService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    //更新线路菜单的状态
    public function toUpdateStatusLineMenu()
    {
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineMenuService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    //删除线路菜单
    public function toDelLineMenu()
    {
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(LineMenuService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }
}
